package cn.com.code.hwjs;

import java.util.Scanner;

/**
 * 学英语
 * https://www.nowcoder.com/practice/1364723563ab43c99f3d38b5abef83bc?tpId=37&tqId=21265&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=
 *
 * @author zhengpei
 * @date 2022/5/15
 */
public class Hwjs42 {

  private static String[] numbers = new String[]{
      "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
      "elven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty"
  };

  private static String[] twieties = new String[]{
      "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"
  };

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
      int str = scanner.nextInt();

      System.out.println(getEn(str));
    }
  }

  private static String getEn(int num) {
    String stren = "error";

    if (num <= 20) {
      stren = numbers[num];
    } else if (num < 100) {
      // 0-99
      int i = num % 10;
      // 10 整除
      if (i == 0) {
        stren = twieties[num / 10];
      } else {
        stren = twieties[num / 10] + " " + numbers[i];
      }
    } else if (num < 1000) {
      // 0-999
      int remainder = num % 100;
      if (remainder == 0) {
        // 100整除
        stren = numbers[num / 100] + " hundred";
      } else {
        stren = numbers[num / 100] + " hundred and " + getEn(remainder);
      }
    } else if (num < 1000000) {
      int remainder = num % 1000;
      if (remainder == 0) {
        stren = getEn(num / 1000) + " thousand";
      } else {
        stren = getEn(num / 1000) + " thousand " + getEn(remainder);
      }
    } else if (num < 1000000000) {
      int remainder = num % 1000000;
      if (remainder == 0) {
        stren = getEn(num / 1000000) + " million";
      } else {
        stren = getEn(num / 1000000) + " million " + getEn(remainder);
      }
    }
    return stren;
  }

}
